#ifndef SHELL_H
#define SHELL_H

#if 0
typedef void (*__board_init)(void);
typedef struct 
{
    void (*__board_init)(void);
} _board_init;
#endif

typedef struct Node
{
    void *item;
    struct Node* next;
    struct Node* prev;
}Node;
typedef struct
{
    void* CurpStack;
    unsigned int StackTop;
    unsigned int StackBottom;
    unsigned int GP;
    unsigned int DelayTick;
    void* func;
}TaskControlBlock;


extern const struct finsh_syscall *finsh_start;
extern const struct finsh_syscall *finsh_end;
// extern const _board_init *board_start;
// extern const _board_init *board_end;
void fsys(char cmd[]);

#if 0
void board_device_init(void);
void board_device_first_init(void);
#endif

void cmd_run(char*cmd);
void str_std(char*std);
unsigned int get_data(char*s);
unsigned int get_hex(char*s);
void display_hex(unsigned char *data,unsigned int len);

#define SECTION(x)                  __attribute__((section(x)))
#define SH_CMD(command, desc)   \
    FINSH_FUNCTION_EXPORT_CMD(command, __cmd_##command, desc)
typedef long (*syscall_func)(unsigned int argc,char*argv[4]);
struct finsh_syscall
{
    const char*     name;       /* the name of system call */

    const char*     desc;       /* description of system call */

    syscall_func func;      /* the function address of system call */
};

#define FINSH_FUNCTION_EXPORT_CMD(name, cmd, desc)      \
                const char __fsym_##cmd##_name[] = #cmd;            \
                const char __fsym_##cmd##_desc[] = #desc;           \
                const struct finsh_syscall SECTION("FSymTab") __fsym_##cmd =           \
                {                           \
                    __fsym_##cmd##_name,    \
                    __fsym_##cmd##_desc,    \
                    (syscall_func)&name     \
                };
#if 0
#define BOARD_INIT(name) \
SECTION("Borad_init") \
const _board_init __init_##name =\
{ \
    (__board_init)&name, \
};
#define BOARD_PRE_INIT(name) \
SECTION("Borad_first_init") \
const _board_init __init_##name =\
{ \
    (__board_init)&name, \
};
#endif

#endif